//
//  ExtensionSystemController.m
//  EasyToTesco2.0
//
//  Created by 杨森 on 2017/3/16.
//  Copyright © 2017年 EasyToTesco. All rights reserved.
//

#import "ExtensionSystemController.h"

#import "InviteListController.h"
#import "CommissionExController.h"
#import "CommissionRunController.h"
#import "CommissionFinalController.h"
#import "CommissionSettlementController.h"
#import "inviteQRCodeController.h"

@interface ExtensionSystemController ()


@property(nonatomic,strong)NSArray *extensionArray;

@end

static NSString *const reuseIdentifier = @"ExtensionSystemIdentifier";

@implementation ExtensionSystemController

- (NSArray *)extensionArray {
    if (!_extensionArray) {
        _extensionArray = @[@"邀请码",@"邀请人记录",@"佣金记录",@"佣金流水记录",@"佣金结算记录",@"佣金申请结算"];
    }
    return _extensionArray;
}

//jiantou


- (void)viewDidLoad {
    [super viewDidLoad];
    
    self.title = @"推广系统";
    
    self.tableView.backgroundColor = BACKGROUND_COLOR;
    self.tableView.rowHeight = HEIGHT/10;
    self.edgesForExtendedLayout = UIRectEdgeNone;
    self.tableView.tableFooterView = [[UIView alloc] init];
    self.navigationItem.leftBarButtonItem = [[UIBarButtonItem alloc] initWithImage:[UIImage imageNamed:@"jiantou"] style:UIBarButtonItemStylePlain target:self action:@selector(popViewController)];
}



#pragma mark - Table view data source
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
    return self.extensionArray.count;
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:reuseIdentifier];
    //12
    if (!cell) {
        cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleValue1 reuseIdentifier:reuseIdentifier];
    }
    
    cell.selectionStyle = UITableViewCellSelectionStyleNone;
    cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;
    
    [cell.imageView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerY.equalTo(cell.mas_centerY);
        make.left.equalTo(cell.mas_left).offset(15);
        make.width.height.mas_equalTo(25);
    }];
    cell.imageView.image = [UIImage imageNamed:[NSString stringWithFormat:@"icon_expand_%ld",indexPath.row]];
    cell.textLabel.text = self.extensionArray[indexPath.row];
    cell.textLabel.font = BOLDFONT(15);

    
    return cell;
}


- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
    NSLog(@"%ld",indexPath.row);
    switch (indexPath.row) {
        case 0:
        {
            inviteQRCodeController *inviteVC = [[inviteQRCodeController alloc] init];
            [self.navigationController pushForm:self.navigationController pushToAndHidden:inviteVC];
            
        }break;
        
        case 1:
        {
            InviteListController *inviteVC = [[InviteListController alloc] init];
            [self.navigationController pushForm:self.navigationController pushToAndHidden:inviteVC];
        }break;
            
        case 2:
        {
            CommissionExController *commissionExVC = [[CommissionExController alloc] init];
            [self.navigationController pushForm:self.navigationController pushToAndHidden:commissionExVC];
        }break;
        
        case 3:
        {
            CommissionRunController *CommissionRunVC = [[CommissionRunController alloc] init];
            [self.navigationController pushForm:self.navigationController pushToAndHidden:CommissionRunVC];
        }
            break;
        case 4:
        {
            CommissionFinalController *CommissionFinalVC = [[CommissionFinalController alloc] init];
            [self.navigationController pushForm:self.navigationController pushToAndHidden:CommissionFinalVC];
        }
            break;
            
        case 5:
        {
            CommissionSettlementController *CommissionSettlementVC = [[CommissionSettlementController alloc] init];
            [self.navigationController pushForm:self.navigationController pushToAndHidden:CommissionSettlementVC];
        }
            break;
            
        default:
            break;
    }

}


- (void)viewWillAppear:(BOOL)animated
{
    [self.navigationController setNavigationBarHidden:NO animated:YES];
    
    [[UIApplication sharedApplication] setStatusBarStyle:UIStatusBarStyleDefault animated:YES];
    self.navigationController.navigationBar.barStyle = UIBarStyleDefault;
    self.navigationController.navigationBar.barTintColor = RGB(245,245,245);
    [self.navigationController.navigationBar setTitleTextAttributes:@{NSForegroundColorAttributeName:[UIColor blackColor]}];
    
}

- (void)viewWillDisappear:(BOOL)animated
{
    [[UIApplication sharedApplication] setStatusBarStyle:UIStatusBarStyleLightContent animated:YES];
    [self.navigationController.navigationBar setBarTintColor:DEFAULT_COLOR];
    [self.navigationController.navigationBar setTitleTextAttributes:@{NSForegroundColorAttributeName:[UIColor whiteColor]}];
}

- (void)popViewController
{
    [self.navigationController popViewControllerAnimated:true];
}

@end
